package com.neu.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.neu.mapper.DeptMapper;
import com.neu.po.Dept;
import com.neu.po.DeptExample;

@Service
public class DeptServiceImpl implements DeptService {
	@Autowired
	private DeptMapper deptMapper;
	
	@Override
	public int insert(Dept dept) {
		return deptMapper.insert(dept);
	}

	@Override
	public int update(Dept dept) {
		return deptMapper.updateByPrimaryKey(dept);
	}

	@Override
	public int detele(int id) {
		return deptMapper.deleteByPrimaryKey(id);
	}

	@Override
	public PageInfo<Dept> getPaged(int pageNum, int pageSize) {
		DeptExample example = new DeptExample();
		PageHelper.startPage(pageNum, pageSize);
		List<Dept> list = deptMapper.selectByExample(example);
		PageInfo<Dept> pageinfo = new PageInfo<>(list);
		
		return pageinfo;
	}

	@Override
	public List<Dept> getAll() {
		DeptExample example = new DeptExample();
		return deptMapper.selectByExample(example);
	}

	@Override
	public Dept getById(int id) {
		return deptMapper.selectByPrimaryKey(id);
	}

}
